import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter);

const index = () => import('@/views')
//路由规则
const routes = [
    {
        path:'/',
        redirect:'/login'
    },
    {
        path:'/login',
        component: () => import('../views/login.vue')
    },
    {
        path:'/main',
        component: () => import('../views/main.vue'),
        children:[
            {
                path:'',
                redirect: 'workbench'
            },
            {
                path:'workbench',
                component: () => import('../views/mainChildren/workbench.vue')
            },{
                path:'msg',
                component:()=> import('../views/mainChildren/MessageManagement.vue')
            }
        ]
    }

]
let router = new VueRouter({
    routes
})
/* 
//路由拦截
router.beforeEach((to, from, next) => {
    const currentToken = window.localStorage.getItem('token');

    if (to.meta.injump) {
        if (currentToken) {
            next();
        } else {
            next("/login")
        }
    } else {
        if (currentToken && to.path == '/login') {
            // console.log(currentToken)
            next('/home')
        } else {
            next()
        }
    }
})

//全局后置守卫
router.afterEach((to, from) => {
    // ...
}) */

export default router